package com.jiaertangshi.jiaer.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.jiaertangshi.jiaer.dto.BaseArea;
import com.jiaertangshi.jiaer.dto.vo.FirstWord;
import com.jiaertangshi.jiaer.service.BaseAreaService;

@RequestMapping("/area")
@RestController
public class BaseAreaController {

	
	@Autowired
	BaseAreaService  baseAreaService;

	@RequestMapping(value = "/location", method = RequestMethod.GET)
    public List<BaseArea> location(@RequestParam(value = "parentid", defaultValue = "99999",required = false) Integer parentid) {
		List<BaseArea>   bas =  	baseAreaService.getAllProvince( parentid);
        return bas;
    }
	
	/*
	 * 根据首字母排序返回全国所有县区
	 */
	@RequestMapping(value = "/locationByFirstWord", method = RequestMethod.GET)
    public  List<FirstWord>  locationByFirstWord() {
		List<FirstWord>   wfs =  	baseAreaService.locationByFirstWord();
        return wfs;
    }

}
